home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / CMD / EDPIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-17  |  1.8 KB  |  77 lines

  1. /*
  2.  * the class EDIT_PIN
  3.  * Copyright (C) 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
  4.  */
  5.  
  6. #include "../stdafx.h"
  7.  
  8. #include "../common/bool.h"
  9.  
  10. #include "edpndlg.h"
  11.  
  12. #include "../resource.h"
  13.  
  14. #include "edpin.h"
  15.  
  16. STAGE* EDIT_PIN::init_new(KBAN_INFO& info, KBAN_DRAW& draw)
  17. {
  18.   return new STAGE_INITIAL;
  19. }
  20.  
  21. const char* EDIT_PIN::get_name(void)
  22. {
  23.   return "Edit:Pin";
  24. }
  25.  
  26. STAGE* EDIT_PIN::STAGE_INITIAL::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  27. {
  28.   XY ac;
  29.   info.grid().xy_pc2ac_with_snap_off(pc, ac);
  30.  
  31.   PRIMITIVE& primitive = info.kban_data().primitive();
  32.   uint layer = info.active_layer().get_pin_layer();
  33.   PIN_LIST& pin_list = primitive.layer(layer).pin_list();
  34.   PIN_ELEMENT* target = pin_list.search(ac);
  35.  
  36.   STAGE* retval;
  37.   if(target != NULL) {
  38.     retval = new STAGE_CHANGE(*target);
  39.   } else {
  40.     retval = this;
  41.   }
  42.   return retval;
  43. }
  44.  
  45. STAGE* EDIT_PIN::STAGE_INITIAL::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  46. {
  47.   return NULL;
  48. }
  49.  
  50. EDIT_PIN::STAGE_CHANGE::STAGE_CHANGE(PIN_ELEMENT& target)
  51.   : m_target(target) {};
  52.  
  53. STAGE* EDIT_PIN::STAGE_CHANGE::init(KBAN_INFO& info, KBAN_DRAW& draw)
  54. {
  55.   draw.draw_primitive_pin_target(m_target);
  56.  
  57.   CEditPinDialog dialog(info.apt_pin_table(), m_target, AfxGetMainWnd());
  58.   draw.draw_primitive_pin_target(m_target);
  59.   int result = dialog.DoModal();
  60.   draw.erase_primitive_pin(m_target);
  61.   if(result == IDOK) {
  62.     m_target = dialog.GetPinElement();
  63.     info.apt_pin_table() = dialog.GetAptTable();
  64.     info.SetModifiedFlag();
  65.   }
  66.   uint layer = info.active_layer().get_pin_layer();
  67.   draw.draw_primitive_pin(m_target, layer);
  68.  
  69.   return new STAGE_INITIAL;
  70. }
  71.  
  72. STAGE* EDIT_PIN::STAGE_CHANGE::redraw(KBAN_INFO& info, KBAN_DRAW& draw)
  73. {
  74.   draw.draw_primitive_pin_target(m_target);
  75.   return this;
  76. }
  77.